﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EzDesk.MobileWeb.ViewModel;
using EzDesk.Core.CoreImpl;
using EzDesk.Core.Model;
using EzDesk.Core;

namespace EzDesk.MobileWeb.Controllers
{
    public class EzControlloerBase : Controller
    {
        // todo: 使用DI加载
        protected ICoreClientService _coreClientService = new CoreClientService();

        protected UserProfile CurrentUserProfile
        {
            get
            {
                return _coreClientService.GetUserProfileById(CurrentUserId);
            }
        }

        protected SimpleUser CurrentSimpleUserInfo
        {
            get
            {
                return _coreClientService.GetSimpleUserById(CurrentUserId);
            }
        }

        protected Guid CurrentUserId
        {
            get
            {
                return new Guid(User.Identity.Name);
            }
        }

        protected virtual ActionResult ReturnView(string r, string txtInfo, object routeValues)
        {
            SetReturnInfoText(txtInfo);
            return View(routeValues);
        }

        protected ActionResult ReturnView(string actionName, string controllerName, string txtInfo, object routeValues)
        {
            SetReturnInfoText(txtInfo);
            return RedirectToAction(actionName, controllerName, routeValues);
        }

        protected void SetReturnInfoText(string txtInfo)
        {
            TempData["txtInfo"] = txtInfo;
        }

    }
}
